package com.letsrpg.wallhaven;

import android.content.Intent;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity implements  ImageListFragment.onItemClickListener{
    private static final String TAG = "ImageGridActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (getSupportFragmentManager().findFragmentByTag(TAG) == null) {
            final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.add(android.R.id.content, ImageListFragment.newInstance(), TAG);
            ft.commit();
        }
    }

    @Override
    public void onItemClick(String id) {
        Intent intent = new Intent(this, ImageActivity.class);
        intent.putExtra("position", id);
        startActivity(intent);
    }
}
